package com.xutong.myfunction.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

import com.xutong.myfunction.R;
import com.xutong.myfunction.custom.CustomHorSor;
import com.xutong.myfunction.entity.ImageItem;

import java.util.ArrayList;
import java.util.List;

public class HorSorActivity extends AppCompatActivity {

    private List<ImageItem> mjImageList;
    private GridView gridView1;
    private String[] mjdescList = new String[]{"智能门禁", "智能家居", "视频监控", "安防报警", "云停车", "云健康"};
    private int[] mjImageIdList = new int[]{R.drawable.ic_main_znmj, R.drawable.ic_main_znjj,
            R.drawable.ic_main_jtjk, R.drawable.ic_main_afbj,
            R.drawable.ic_main_zhtc, R.drawable.ic_main_yjk};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hor_sor);

        gridView1 = (GridView) findViewById(R.id.gridView1);
        setData();

        CustomHorSor.setGridView(this,gridView1,mjImageList,5);
        gridView1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                ImageItem imageItem = (ImageItem) parent.getItemAtPosition(position);
                if (imageItem.getImageDesc().equals(mjdescList[1])) {
                    //智能家居

                }
            }
        });

    }

    /**
     * 设置数据
     */
    private void setData() {
        mjImageList = new ArrayList<ImageItem>();
        for (int i = 0; i < mjImageIdList.length; i++) {
            ImageItem item = new ImageItem();
            item.setImageDesc(mjdescList[i]);
            item.setimageId(mjImageIdList[i]);
            mjImageList.add(item);
        }
    }

}
